.TH E1432_AUTO_RANGE 3 E1432
.SH NAME
e1432_auto_range \- Automatically set the input range
.IX e1432_auto_range(3) 3
.SH SYNOPSIS
.cS
SHORTSIZ16 e1432_auto_range(E1432ID hw, SHORTSIZ16 ID, FLOATSIZ64 meas_time)
.cE
.SH DESCRIPTION
\fIe1432_auto_range\fR attempts to set the input range of a single
channel or group of channels.  It tries to pick a range which puts the
input signal near full scale but which does not overload the input.

\fIhw\fR must be the result of a successful call to
\fIe1432_assign_channel_numbers\fR, and specifies the group of
hardware to talk to.

\fIID\fR is either the ID of a group of channels that was obtained with a
call to \fIe1432_create_channel_group\fR, or the ID of a single channel.

\fImeas_time\fR specifies how long to monitor the input channels, in
seconds, before deciding whether the range is OK, or needs to be
increased, or decreased.  If the range needs to be changed on any
channel, then the channels are again monitored for \fImeas_time\fR
seconds and checked to see if the range needs to be changed or not.
This is done in a loop until all input channels reach a range at which
there is neither an overload nor an under-range.

As a special case, if the \fImeas_time\fR is specified as exactly
zero, the auto range will estimate an appropriate measurement time.
The estimate uses the formula: meas_time=blocksize*0.1/span.

The algorithm normally will change the input ranges up or down in
order to reach the "best" range.  However,
\fIe1432_set_auto_range_mode\fR can be used to modify this algorithm.
If the auto range mode is set to \fBE1432_AUTO_RANGE_MODE_UP\fR for a
given channel, then the auto range will only increase the input range
(or leave it the same) but will not decrease the range setting for
that channel.  Similarly, if the auto range mode is set to
\fBE1432_AUTO_RANGE_MODE_DOWN\fR for a given channel, then the auto
range will only decrease the input range (or leave it the same) but
will not increase the range setting.

If a channel is at the maximum range setting and the input is still
overloaded, the channel is left at the maximum range and no error is
generated.  If a channel is at the minimum range setting and the input
is still under-ranged, the channel is left at the minimum range and no
error is generated.

If this function is called when a measurement is running, it will
change the ranges of the channels "on the fly", leaving the
measurement running with the input channels at the new ranges.

If this function is called when no measurement is running, it will
internally run a measurement, do the auto-range, and then stop the
internal measurement.  The internal measurement is mostly like any
other measurement, but it temporarily turns off VME interrupts from
the module, disables the Local Bus, and deactivates any sources,
so that the auto-range will not have any unexpected effects outside of
the module.

Due to DSP limitations, auto-range does \fBNOT\fR work on an E1433 if
the current clock frequency (as set by \fIe1432_set_clock_freq\fR) is
greater than 128 kHz.  If an auto-range is attempted when the clock
frequency is greater than 128 kHz, an error is returned.

.SH "RESET VALUE"
Not applicable.
.SH "RETURN VALUE"
Return 0 if successful, a (negative) error number otherwise.
.SH "SEE ALSO"
.na
e1432_set_auto_range_mode, e1432_set_clock_freq
.ad
